package net.solvetheriddle.wwclient.activity;

import java.util.ArrayList;
import net.solvetheriddle.wwclient.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class StatisticsActivity extends Activity {

  // UI objects
  private ListView statisticsLV;

  private ArrayList<String> statisticsItems;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.statistics);

    statisticsLV = (ListView) findViewById(R.id.statisticsListView);

    // Manage the StatisticsListView
    statisticsItems = new ArrayList<String>();
    initStatisticsList(statisticsItems);
    ArrayAdapter<String> statisticsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, statisticsItems); // android.R.layout.simple_list_item_1
    statisticsLV.setAdapter(statisticsAdapter);

    statisticsLV.setOnItemClickListener(new OnItemClickListener() {

      public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        Bundle b = new Bundle();
        b.putInt("statName", arg2);
        Intent i = new Intent(statisticsLV.getContext(), StatisticsGraphActivity.class);
        i.putExtras(b);
        startActivity(i);
      }
    });

  }

  private void initStatisticsList(ArrayList<String> statisticsItems) {
    statisticsItems.add("Denní");
    statisticsItems.add("Týdenní");
    statisticsItems.add("Měsíční");
    statisticsItems.add("Celkové");
  }
}
